#include <pthread.h>
#include <iostream>
class Mutex
{
public:
    Mutex(pthread_mutex_t *mtx)//初始化
    :_pmtx(mtx)
    {}
    void lock()
    {
        pthread_mutex_lock(_pmtx);
    }
    void unlock()
    {
        pthread_mutex_unlock(_pmtx);

    }
    ~Mutex()
    {}
private:
    pthread_mutex_t *_pmtx;
};

class lockGuard
{
public:
    lockGuard(pthread_mutex_t *mtx)
    :_pptx(mtx)
    {
        _pptx.lock();
    }
    ~lockGuard()
    {
        _pptx.unlock();
    }
private:
    Mutex _pptx;
};